package bma.common.langutil.jdbc;

import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.util.Date;

public class CommonFieldValues extends FieldValues {

	private static final long serialVersionUID = 3690760613408291128L;

	public static final Object CONST = new Long(0);

	public CommonFieldValues() {
		super();
	}

	public void addValue(String fname, Type type, Object obj) {
		add(fname, type, obj, null);
	}

	public void addValue(String fname, Type type, Object obj, String exp) {
		add(new FieldValue(fname, type, obj, exp));
	}

	public void addInt(String fname, int i) {
		add(fname, Integer.class, new Integer(i));
	}

	public void addInt(String fname, int i, String exp) {
		add(fname, Integer.class, new Integer(i), exp);
	}

	public void addLong(String fname, long i) {
		add(fname, Long.class, new Long(i));
	}

	public void addLong(String fname, long i, String exp) {
		add(fname, Long.class, new Long(i), exp);
	}

	public void addFloat(String fname, float i) {
		add(fname, Float.class, new Float(i));
	}

	public void addFloat(String fname, float i, String exp) {
		add(fname, Float.class, new Float(i), exp);
	}

	public void addDouble(String fname, double i) {
		add(fname, Double.class, new Double(i));
	}

	public void addDouble(String fname, double i, String exp) {
		add(fname, Double.class, new Double(i), exp);
	}

	public void addString(String fname, String s1) {
		add(fname, String.class, s1);
	}

	public void addString(String fname, String s1, String exp) {
		add(fname, String.class, s1, exp);
	}

	public void addLikeString(String fname, String s1) {
		StringBuffer buf = new StringBuffer(s1.length() + 20);
		buf.append('%');
		SQLUtil.parseLikeString(s1, buf);
		buf.append('%');
		addString(fname, buf.toString(), "LIKE");
	}

	public void addTimestamp(String fname, Date timestamp) {
		add(fname, Timestamp.class, timestamp);
	}

	public void addTimestamp(String fname, long timestamp) {
		addTimestamp(fname, new Date(timestamp));
	}

	public void addTimestamp(String fname, Date timestamp, String exp) {
		add(fname, Timestamp.class, timestamp, exp);
	}

	public void addTimestamp(String fname, long timestamp, String exp) {
		addTimestamp(fname, new Date(timestamp), exp);
	}

	public void addConst(String fname, String s1) {
		add(fname, CONST, s1);
	}

	public void addConst(String fname, String s1, String exp) {
		add(fname, CONST, s1, exp);
	}

	public void addConstInt(String fname, int i) {
		addConst(fname, Integer.toString(i));
	}

	public void addConstInt(String fname, int i, String exp) {
		addConst(fname, Integer.toString(i), exp);
	}

	public void addSysdate(String fname) {
		addTimestamp(fname, System.currentTimeMillis());
	}

	public void addSysdate(String fname, String exp) {
		addTimestamp(fname, System.currentTimeMillis(), exp);
	}

}
